namespace MyBlog.Model
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;

    [Serializable]
    public partial class ArticleCommentModel
    {
        public ArticleCommentModel()
        {
            ArticleCommentModels = new List<ArticleCommentModel>();
        }

        public int ID { get; set; }

        public int? ParentID { set; get; }

        public bool IsLoop { set; get; }

        public ArticleCommentModel Parent { set; get; }

        public List<ArticleCommentModel> ArticleCommentModels { get; set; }

        public int ArticleId { get; set; }

        [StringLength(50)]
        public string VisitorName { get; set; }

        [StringLength(50)]
        public string VisitorIP { get; set; }

        [StringLength(50)]
        public string CommentUid { set; get; }

        [Required]
        public string Content { get; set; }

        public DateTime CommentTime { get; set; }

        public  ArticleModel Article { get; set; }

        public string AgreeUsers { get; set; }

        public int AgreeCount
        {
            get
            {
                if (!string.IsNullOrWhiteSpace(AgreeUsers))
                {
                    if (AgreeUsers.Contains("&"))
                    {
                        return AgreeUsers.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries).Length;
                    }
                    return 1;
                }
                return 0;
            }
        }

    }
}
